package com.woniu.springboot.product.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.woniu.springboot.product.blockException.CustomException;
import com.woniu.springboot.product.feign.OrderFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhaolei
 * @date 2021/5/12 - 1:33
 */
@RestController
@RequestMapping(value = "/products")
public class ProductController {
    @Autowired
    private OrderFeign orderFeign;
    @GetMapping(value = "/getProducts")
    public String shopping(){
        orderFeign.getOrders();
        return "买入成功";
    }

    @GetMapping(value = "/msg")
    public  String msg(){
        System.out.println("1+1" + "=" + "3    ×  0分");
        return "小点点";
    }

    @GetMapping(value = "/getObj")
    @SentinelResource(value = "/getObj", blockHandlerClass = CustomException.class,
                        blockHandler = "error1")
    public String getObj(){
        System.out.println("点击，冲压");
        return "点击成功";
    }

}
